package com.maya.medicalwastes.adapter;

import android.view.View;
import android.widget.CheckBox;
import android.widget.TextView;

import androidx.annotation.Nullable;
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.maya.medicalwastes.R;
import com.maya.medicalwastes.bean.SearchBean;
import com.maya.medicalwastes.bean.SearchItemBean;
import com.maya.medicalwastes.entity.KeyBean;
import com.maya.medicalwastes.entity.MenuEntity;
import com.maya.medicalwastes.util.SearchType;
import com.maya.medicalwastes.util.ToastUtils;

import java.util.List;

/**
 * @author created by fuguoyong
 * 版本：1.0
 * 创建日期：2020-11-19 13
 * 描述：FirstMenuAdapter
 */
public class BarcodeAdapter extends BaseQuickAdapter<SearchItemBean, BaseViewHolder> {

    private int  type=1;
    public BarcodeAdapter(int layoutResId, @Nullable List<SearchItemBean> data) {
        super(layoutResId, data);
    }

    public void type(int type){
        this.type=type;
    }

    @Override
    protected void convert(BaseViewHolder helper, SearchItemBean item) {
        helper.setText(R.id.tv_qrcode_type,SearchType.getWareType(item.getCategory())).setText(R.id.tv_qrcode, item.getQrcodeInfo()).setText(R.id.create_time, item.getCreateTime() )
                  .setText(R.id.text_num, item.getId()).setText(R.id.text_curPrice, item.getUserState().equals("1")?"未下载":"已下载");
        TextView mView = helper.getView(R.id.tv_do);
    if (item.isCheck()){
    helper.setChecked(R.id.check,true);
        }else {
       helper.setChecked(R.id.check,false);
    }
    if (item.getUserState().equals("3")){
        mView.setEnabled(false);
        mView.setTextColor(mContext.getResources().getColor(R.color.gray_3));

    }else {
        mView.setEnabled(true);
        mView.setTextColor(mContext.getResources().getColor(R.color.colorReceiveText));
    }
        helper.addOnClickListener(R.id.tv_do);
   helper.setOnClickListener(R.id.check, new View.OnClickListener() {
       @Override
       public void onClick(View view) {
           if (item.isCheck()){
               item.setCheck(true);
           }else {
               item.setCheck(false);
           }

       }
   });
    }

}